package com.cst.intercepterdemo.intercepter;

import com.cst.intercepterdemo.context.IInterceptContext;
import com.cst.intercepterdemo.model.Application;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * <ul>
 * <li>文件名称 : com.cst.intercepterdemo.intercepter.ApplicationTypeValidator
 * </li>
 * <li>版权所有 : 版权所有(C)2016-2020</li>
 * <li>公 司 : CST</li>
 * <li>创建时间 : 2016/12/9</li>
 * <li>修改记录 : </li>
 * </ul>
 * 类说明：
 *
 * @author Allen
 * @version 1.0
 */
@Component("apptype2")
public class ApplicationType2Validator extends AbstractApplicationValidator{

    private Logger logger = LoggerFactory.getLogger(ApplicationType2Validator.class);

    @Override
    protected boolean doAppIntercept(Application application, IInterceptContext context) {
        logger.info("[app type 2] validator worked.");
        boolean isPass = application.getType()==2;
        logger.info("[app type 2] valide:{}",isPass);
        if(!isPass){
            context.addErrorCode("app.not.type2");
        }
        return isPass;
    }
}
